package circle.cifradorTexto.negocios;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SalvarAbrir {
	private SalvarAbrir(){
		
	}
	
	static FileOutputStream arquivo;
	static ObjectOutputStream obj;
	public static void salvar(File pArquivo, String pTexto){
		try{
			arquivo = new FileOutputStream(pArquivo);
			obj = new ObjectOutputStream(arquivo);
			
			obj.writeObject(pTexto);
			obj.close();
			
	    } catch (IOException e) {  
	    	e.printStackTrace();
	    } finally {
	    	
	    }
	}
	
	static FileInputStream arquivoInput;
	static ObjectInputStream objInput;
	
	static String textoLinha;
	public static String abrir(File pArquivo) throws IOException{
		
		try {
			arquivoInput = new FileInputStream(pArquivo);
			objInput = new ObjectInputStream(arquivoInput);
			
			while (true) {
				Object oo = objInput.readObject();
				textoLinha = (String) oo;
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (EOFException e){
			e.printStackTrace();
		}
		
		return textoLinha;
	}
}
